Skip to content

feat(canvas): web analytics template + date-range picker#2657

Merged
adamleithp merged 2 commits into
mainfrom
feat/canvas-web-analytics
Jun 15, 2026
Merged

feat(canvas): web analytics template + date-range picker#2657
adamleithp merged 2 commits into
mainfrom
feat/canvas-web-analytics

Conversation

@adamleithp

@adamleithp adamleithp commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What

A new Web analytics canvas template that drives the agent to build a PostHog-style board (KPI row, visitor trends with prior-period comparison, sources, geography, retention, active hours) for a selectable date range.

TLDR: web analytics

image image image image 2026-06-15 12 35 04

Highlights

  • New catalog components: Heatmap (day×hour activity) and RetentionGrid (cohort bars) — schema + bodies + registry wiring.
  • DateTimePicker in the canvas toolbar (quill), shown in view and edit:
    • Named ranges (e.g. "Last 7 days") roll to now; Custom pins to absolute from/to with a human-readable label.
    • View mode re-runs the board's queries for the window; edit mode feeds the agent's next build via a [Range] prompt line.
    • Optimistic label + spinner while applying; clears on success or failure (no stuck-disabled state).
  • Multi-value query refresh: queries declare a shape (scalar/column/labels/matrix/pairs/retention) mapped onto props via a JSON-pointer setter. Mis-shaped numeric columns fail (instead of charting zeros); identical values skip the file write (no poll churn).
  • Timezone-safe time windows: {date_from}/{date_to} (+ _prev for comparison series) substituted as UTC-instant toDateTime(<unix>) literals.
  • Channels remember collapsed state in localStorage (closed by default).
  • Tables use quill's stickyHeader with a capped scroll viewport; Filter button disabled (not wired yet).

Test plan

  • pnpm --filter @posthog/core test — 1415 pass (incl. new dashboardQueryService shape-mapping tests).
  • pnpm typecheck (core/ui/host-router) + biome lint clean.
  • Manual: create a Web analytics canvas, build it, change the date range in view (rolls + re-queries) and edit (feeds the agent).

🤖 Generated with Claude Code

@adamleithp adamleithp added the Stamphog This will request an autostamp by stamphog on small changes label Jun 13, 2026
@adamleithp adamleithp enabled auto-merge (squash) June 13, 2026 09:54
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/core/src/canvas/dashboardQueryService.test.ts:29-108
**Non-parameterised shape tests**

The six happy-path shape cases (`scalar`, `column`, `labels`, `matrix`, `pairs`, `retention`) share the same fixture → run → `toMatchObject` structure and could be collapsed into a single `it.each` table. The two failure tests (lines 82-101) also share `expect(r.ok).toBe(false)` and are a natural second table. Keeping them as individual `it` blocks violates the project's "always prefer parameterised tests" convention and makes the list harder to extend when new shapes are added.

### Issue 2 of 2
packages/ui/src/features/canvas/components/ChannelsList.tsx:58-62
Closed channels write `"0"` to `localStorage`, but the comment above `useChannelOpen` says "only an explicit open is stored." The `"0"` entries are redundant because absent keys are also read as `false`; over many channels they accumulate needless storage entries. Remove the `"0"` write (or remove the stored key entirely on close) to match the documented intent.

```suggestion
      try {
        if (next) {
          localStorage.setItem(key, "1");
        } else {
          localStorage.removeItem(key);
        }
      } catch {
        // Ignore storage failures (private mode, quota) — state still works in-session.
      }
```

Reviews (1): Last reviewed commit: "feat(canvas): web analytics template + d..." | Re-trigger Greptile

Comment thread packages/core/src/canvas/dashboardQueryService.test.ts Outdated
Comment thread packages/ui/src/features/canvas/components/ChannelsList.tsx
@adamleithp adamleithp disabled auto-merge June 13, 2026 10:08
Canvas template system (Dashboard / Web analytics / Blank) with a create
picker, per-template agent prompts + component allow-lists, rename, the
Quill component pass, and the showcase seed — plus the Web analytics
template and its date-range picker.

- Templates: canvasTemplates + templateSchemas + CanvasTemplatesService,
  templateId on canvas records, NewCanvasMenu picker, per-template chat
  suggestions.
- Web analytics template: KPI row, visitor trends with prior-period
  comparison, sources, geography, retention, active hours.
- New catalog components: Heatmap and RetentionGrid.
- DateTimePicker in the toolbar (quill): named ranges roll to now, Custom
  pins to absolute; view re-runs queries, edit feeds the agent via a
  [Range] prompt line.
- Multi-value query refresh: shape-tagged queries mapped onto props via a
  JSON-pointer setter; timezone-safe {date_from}/{date_to}(+_prev) tokens.
- Channels remember collapsed state in localStorage (closed by default).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adamleithp adamleithp force-pushed the feat/canvas-web-analytics branch from 75f4d8f to b9a5559 Compare June 13, 2026 21:59
@adamleithp adamleithp enabled auto-merge (squash) June 13, 2026 21:59
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

React Doctor found 2 issues in 2 files · 2 warnings.

2 warnings

src/features/canvas/components/WebsiteDashboard.tsx

src/features/canvas/genui/bodies.tsx

Reviewed by React Doctor for commit 47bcf9c.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates denied this PR: it modifies dependencies/toolchain (pnpm-lock.yaml, package.json files, pnpm-workspace.yaml) and exceeds the size ceiling significantly (3783 lines, 48 files across two feature areas). This requires human review.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jun 13, 2026
@adamleithp adamleithp added the Stamphog This will request an autostamp by stamphog on small changes label Jun 14, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates denied this PR: it modifies dependencies/toolchain files (pnpm-lock.yaml, multiple package.json files, pnpm-workspace.yaml) and far exceeds the size ceiling at 3783 lines across 48 files spanning two feature areas. Human review is required.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jun 14, 2026
- Parameterize dashboardQueryService shape-mapping tests via it.each
- Remove redundant "0" localStorage writes for closed channels

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adamleithp adamleithp requested a review from raquelmsmith June 15, 2026 11:35

@raquelmsmith raquelmsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stuff to fine-tune here, assuming you'll do that later?

id: "web-analytics",
name: "Web analytics",
description:
"A PostHog-style web analytics board: KPI row, visitor trends, sources, geography, retention and active hours — all driven by a date range.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"A PostHog-style web analytics board: KPI row, visitor trends, sources, geography, retention and active hours — all driven by a date range.",
"A dashboard for web analytics: KPI row, visitor trends, sources, geography, retention and active hours, filterable by date range.",

Comment on lines +110 to +131
const BLANK_SUGGESTIONS: CanvasSuggestion[] = [
{
label: "Landing page",
prompt:
"Build a marketing landing page with a hero (headline, subtitle, call to action), a grid of feature cards, and a closing section.",
},
{
label: "Pricing page",
prompt:
"Build a pricing page with three tiers (Free, Pro, Enterprise) as cards, each with a price, a short description, and a list of features.",
},
{
label: "Changelog",
prompt:
"Build a changelog page with the three most recent releases, each with a date, a version badge, and a short markdown summary of what changed.",
},
{
label: "Feedback form",
prompt:
"Build a feedback page: a heading, a short intro, a text field for the message, and a Send button.",
},
];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't seem like great suggestions for our users' use-cases

@adamleithp adamleithp merged commit 44a64b6 into main Jun 15, 2026
23 checks passed
@adamleithp adamleithp deleted the feat/canvas-web-analytics branch June 15, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants